!
! to make a table for the comparion between the Model and INCA observations. 
!
! INCA observations are taken from Gayet et al. (2004), JGR. 
!
! Gayet et at., 2004: Cirrus cloud microphysical and optical properties at southern and nothern midlatitudes during 
! the INCA experiment, JGR. 
! 
!
  Program main
  implicit none

  integer mT , ncase
  parameter (mT=70, ncase=6)

! mean, 25%, 50%, 75%
  real*4 ni_model( 4, mT) 

  character*20 casename(ncase)
  character*200 filename
  character*200 filepath
  character*100 ctemp

  integer icase, itime, ikk, iregion, iread, ix, ilev, iT

! case name
  data casename /'hf03', 'hfht01', 'hfht0101', 'hfht0102', 'hfht0103', 'hfht0104'/

  icase=6
  open(300, file='../Data/REI_Tk_Krameretal2008_'//trim(casename(icase))//'.txt')

   filepath = '/scr1/minghuai/CAM_IMPACT/Cirrus_KB08/Data/'
   filename = trim(filepath)//'REI_pdf_KB08_TEST02_'//trim(casename(icase))//    &
            '_01annu_cld1.0e-3_Ni1.0e_4_Krameretal2008.dat'

   open(200, file=trim(filename))
   print *, trim(filename)
   read(200, *) 
   read(200, *)
   do iT=1, mT
      do iread=1, 102
       read(200, *)
      end do
      do ix=1, 4
         read(200, 212) ctemp, ni_model(ix, iT)
      end do 
   end do  ! end iT 
  close(200)
212  format(3x, a15, e15.8)
 
  write(300, 305)  'Temperature', 'Mean', '25%', '50%', '75%'
  do iT=1, mT
    write(300, 310) iT+180-0.5,   (ni_model(ix, iT), ix=1, 4)
  end do
305 format (10x, a15, a15, a15, a15, a15)
310 format (10x, f15.2, 4f15.8)

end program main


